package org.misty.seckill.redis;

import org.misty.seckill.model.Goods;

public class GoodsKey extends BaseKeyPrefix {
  public static final GoodsKey SECKILL_STOCK = getSeckillStockKey(0);
  public static final GoodsKey SECKILL = getSeckillKey(0);
  public static final GoodsKey SECKILL_USERS = getSeckillUsersKey(0);
  public static final GoodsKey SECKILL_QUEUING = getSeckillQueuing(300);

  public GoodsKey(int expiryInSec, String prefix) {
    super(Goods.class, expiryInSec, prefix);
  }

  public static GoodsKey getSeckillStockKey(int expiryInSec) {
    return new GoodsKey(expiryInSec, "sStock");
  }

  public static GoodsKey getSeckillKey(int expiryInSec) {
    return new GoodsKey(expiryInSec, "seckill");
  }

  public static GoodsKey getSeckillUsersKey(int expiryInSec) {
    return new GoodsKey(expiryInSec, "seckill-users");
  }

  public static GoodsKey getSeckillQueuing(int expiryInSec) {
    return new GoodsKey(expiryInSec, "seckill-queuing");
  }

  public static String queuingKey(long userId, long queuingId) {
    return "" + userId + "." + queuingId;
  }
}
